from simple_game_Rate import *

magic_type_name = ["Fire","Freeze","Thunder","Wind"]
soldier_type_name = ["Warrior","rage","Guard","Assassin"]

class Magic:
    def __init__(self, name, type, life, attack_value, hit_rate, magic_value):
        self.name = name                #法师名称
        self.type = type                #法师类型    
        self.life = life                #法师生命
        self.attack_value = attack_value#法师伤害
        self.hit_rate = hit_rate        #命中概率
        self.magic_value = magic_value  #法师蓝量

    #法师的行为选择
    def op_magic(self,op_num_magic,attack_ob):
        if op_num_magic == 1:
            self.attack(attack_ob)
        else:
            self.sleep()    

    #法师选择攻击对象
    def attack(self,attack_ob):
        if probably_rate(self.hit_rate):
            attack_ob.life -= self.attack_value
            print("%s法师造成了"+str(self.attack_value)+"点的伤害")
        else:
            print("法术被敌方躲闪" % self.name)

    #法师选择回蓝
    def sleep(self):
        print("%s正在回复中" % self.name)
        

class Soldier():
    def  __init__(self, name, type, life, attack_value, step, distance):
        self.name = name                #战士名称
        self.type = type                #战士类型    
        self.life = life                #战士生命
        self.attack_value = attack_value#战士伤害
        self.step = step                #移动步数    
        self.distance = distance        #战士距离


    #战士的行为选择
    def op_soldier(self,op_num_soldier,attack_ob):
        if op_num_soldier == 0:
            self.defense()
        elif op_num_soldier == 1:
            self.move()
        elif op_num_soldier == 2 :
            if self.distance > 0:
                print("%s战士试图将空气砍完")
            else:     
                self.attack(attack_ob)    

    #战士选择防御
    def defense(self):
        if Magic.attack():
            self.life -= (Magic.attack)*0.1
            print("%s战士防御住了法师的法术") 
        else:
            print("一场风吹过，场面一度尴尬")

    #战士选择移动
    def move(self):
        if Magic.attack():
            self.life -= (Magic.attack)
            self.distance -=self.step
            print("%s战士扛着伤害前进")
        else:
            self.distance -=self.step
            print("%s战士偷偷前进")    

    #战士选择攻击
    def attack(self,attack_ob):
        attack_ob.life -= self.attack_value
        print("%s战士造成了"+str(self.attack_value)+"点的伤害")

    #打印战士当前属性
    def info(self):
        print("战士%s， 剩余血量%i, 距离法师距离%i" % (self.name, self.life, self.distance))        
